<template>
  <base-panel-xs class="gross">
    <div class="data-statistics">
      <div class="statistical-data" v-for="item in list" :key="item.id">
        <span class="num">{{ item.num }}</span>
        <span class="text">{{ item.text }}</span>
      </div>
    </div>
  </base-panel-xs>
</template>

<script>
import axios from 'axios';
import BasePanelXs from './BasePanelXs.vue';

export default {
  components: {
    BasePanelXs,
  },

  data() {
    return {
      origin: {
        total: 0,
        online: 0,
        offline: 0,
        alarm: 0,
      },
    };
  },

  computed: {
    list() {
      return [
        { id: 1, num: this.origin.total, text: '总量' },
        { id: 2, num: this.origin.online, text: '在线量' },
        { id: 3, num: this.origin.offline, text: '离线量' },
        { id: 4, num: this.origin.alarm, text: '预警量' },
      ];
    },
  },

  created() {
    this.getcomments();
  },

  methods: {
    getcomments() {
      axios({
        method: 'get',
        url: 'http://mock-api.com/vKVvqRK8.mock/get-stats-overview',
      }).then((res) => {
        console.log(res.data);
        this.origin = res.data;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.gross {
  height: 8.519vh;
  margin-bottom: 1.852vh;
}

.data-statistics{
  display: flex;
  justify-content: space-between;
  height: 100%;
  padding: 0 1.875vw 0 1.719vw;
  align-items: center;
  text-align: center;
  line-height: 1;
  flex-grow: 1;
}

.statistical-data{
  display: inline-flex;
  color:#fff;
  flex-direction:column;
  justify-content: space-between;
  overflow: hidden;
}

.num {
  font-size: 1.25vw;
  font-weight: bold;
  margin-bottom: 1.019vh;
  text-shadow: 0 0 .5em rgba(255,255,255,.5);
}

.text {
  font-size: .885vw;
}
</style>
